include $(TOPDIR)/rules.mk

PKG_NAME:=doorsvr
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install


include $(INCLUDE_DIR)/package.mk

define Package/doorsvr
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+libubox +libopenssl +libsqlite3 +libevent2 +libevent2-core
  TITLE:=door server for openwrt
endef

define Package/doorsvr/description
	Network server test for openwrt
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
     
define Package/doorsvr/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/server-example $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/client-example $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/keysvr $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/keycli $(1)/usr/bin/
	$(INSTALL_DIR) $(1)/etc/doorsvr
	$(INSTALL_DIR) $(1)/etc/init.d/
	$(CP) -rf ./files/* $(1)/etc/doorsvr
	$(CP) -rf ./files/doorsvr.init $(1)/etc/init.d/doorsvr
endef

$(eval $(call BuildPackage,doorsvr))


